Skip to content

from_lavc_vid_conv: guard NULL conversion in get_av_to_uv_conversion - #504

Merged
mpiatka merged 1 commit into
CESNET:masterfrom
armelvil:fix/lavc-null-conversion
Aug 21, 2026
Merged

from_lavc_vid_conv: guard NULL conversion in get_av_to_uv_conversion#504
mpiatka merged 1 commit into
CESNET:masterfrom
armelvil:fix/lavc-null-conversion

Conversation

@armelvil

Copy link
Copy Markdown
Contributor

When running encoder viability tests with file input to gauge codec suitability, I ran into an UltraGrid SEGV situation.

Root cause:
get_av_to_uv_conversion_int() can return a valid struct with conversion == NULL (the direct pixfmt-map, decoder, or CUDA early-return paths).
Since ecd4c53, the VERBOSE message in get_av_to_uv_conversion() unconditionally dereferences ret->conversion->uv_codec, crashing whenever a decoder emits a directly-mapped format (e.g. HEVC VAAPI -> NV12)

"-t file:$arg" was my vector for discovering it.

Fix:
guard the dereference. When conversion is NULL, fall through to the plain "converting A to B" message (which is accurate for those paths). Doing the same short-circuit elsewhere is unnecessary — the consumer in do_av_to_uv_conversion() already guards conversion != NULL.

I performed a local build with the patched file, ran through a couple of tests and it seemed OK.

It seems to have been introduced in ecd4c53.

get_av_to_uv_conversion_int() can return a valid struct with
conversion == NULL (direct pixfmt map, decoder, or CUDA early-return
paths), but since ecd4c53 the VERBOSE message unconditionally
dereferences ret->conversion->uv_codec, SEGV when -t file: decodes to a
directly-mapped format.

Regression introduced in ecd4c53.
@mpiatka

mpiatka commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

I was able to reproduce this with

./uv -t testcard -c libavcodec:codec=J2K -d dummy --param lavc-use-codec=rgb24 --verbose=7

The fix looks good to me.
Thanks

@mpiatka
mpiatka merged commit 2476a4f into CESNET:master Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants